from utils.logger import Logger
from utils.file_utils import read_file, save_to_file
from utils.api_client import APIClient
from utils.test_case_utils import generate_test_cases

def main(input_file_path, output_file_path):
    # 初始化日志
    global logger
    logger = Logger().get_logger()

    # 初始化API客户端
    with open("config/api_keys.json", "r") as f:
        api_key = eval(f.read())["deepseek_api_key"]
    api_client = APIClient(api_key=api_key, base_url="https://api.deepseek.com/v1/")

    # 读取输入文件
    input_text = read_file(input_file_path)

    # 生成测试用例
    test_cases = generate_test_cases(api_client, input_text)

    # 保存输出文件
    save_to_file(output_file_path, test_cases)

    logger.info(f"测试用例已生成并保存至: {output_file_path}")

if __name__ == "__main__":
    main(
        input_file_path="data/input/aaa.txt",
        output_file_path="data/output/generated_test_cases.md"
    )